|
STLink-V2ST Microelectronics
|
|
|
STMicroelectronics ST Visual develop IDE for developing ST7 and STM8 applications |
|
|
arduino IDEArduino
|
Tim's I2C Dual Motor Driver [Version 2]
This is Version 2 of my previous Tim's I2C Dual Motor Driver.
This supersedes this Project. Tim's I2C Dual Motor Driver - Share Project - PCBWay
What has changed?
- On my previous version of my motor driver I pus all the Quadratic Encoder pins on the same Port of the Microcontroller.
- Having all the the quadratic signals on the same port meant that when positioning a motor using there quadratic encoder, only one motor cold be positioned at a time. Both motors could not be positioned at the same time. (It was a novice mistake)
- Version 2 now has the the Quadratic inputs for each motor on separate Ports, this means that they can be positioned at the same time.
- Also the Station inputs are on there own Port.
- Because I have changed what which pin controls, it requires a new version of the PCB.
- I have also made it possible to have two independent motor voltages. By default these are linked, but there is a solder jumper that just needs cutting to separate them.
- A minor bug in the firmware have also been addressed. (Version 2 firmware cannot be used on a version 1 board.)
About
The board can control two motors with quadratic encoders and a station to set a reference point.
The board uses I2C to communicate with an attached Microcontroller.
The Motor Driver is controlled via the I2C bus.
Each board can have its own unique I2C Address.
Not using the reserved Addresses over 100 in theory can be attached to one I2C bus. (Addresses 10 to 127 probably) 7-bit Address.
The is a system to reset the I2C default address to 0x30.
There are two sockets for the I2C to that the boards can be daisy-chained, end to end.
There there are solder jumpers to enable pull-up resistors, depending on muti-board setup or single board setup, these can be enabled/disabled.
Motor Power
Version 2 can have independent motor voltages.
There is a solder jumper on the back of the board. This is connected by default to link the Motor Power.
To have independent Power supplies the link needs to be cut.
The Microcontroller is the STM8S103F3
According to the Data Sheet, this can run with 2.95 to 5.5 V operating voltage (VCC).
Caution should be taken when programming, The ST-Link is 3.3v.
My early single motor driver had more AI,I was a little limited for pins and memory, as I am controlling two motors with this. The AI has been reduced, it still has inputs for quadratic encoders and a station, these enable it to know the rotation and position of the motors.
I was able to use the current sense from the DRV8876, so the load on the motors can be retrieved from communication via I2C.
There are LEDs for diagnostics.
LED Diagnostics
Two Yellow LEDs, for Motor Power. (The brightness of these two will depend on the Motor Power Voltage, 37 volts limit.)
One Yellow LED for VCC.
There is a red LED on the SDA line to show activity.
For each motor there is a red LED to show a fault.
For each motor there is a blue LED to show Motor on.
For each motor there is a Green LED to show motor direction, forward or reverse (on/off).
Programming
There are Pads for programming the STM8S103F3
To program the STM8S103F3 will require STMicroelectronics "ST Visual Programmer"
STMicroelectronics "ST Visual Programmer" is part of "ST MCU toolset".
I have done .s19 file for use with the "ST Visual Programmer".
An ST-Link is required.
The Drivers used are DRV8876
The DRV8876 is an N-channel H-bridge motor driver, the board has two of these.
They have 4.5-V to 37-V operating supply voltage range.
3.5-A Peak. On the board I have put places for Current limit resistors.
Supports 1.8-V, 3.3-V, and 5-V logic inputs. (The STM8S103F3 operates at 2.95 to 5.5 V)
On the board the DRV8876 are set to PH/EN Control Mode.
The nSleep is fixed High, so no low power mode.
I have connected the IPROPI to the STM8S103F3 so current readings can be sensed.
There are connections for a Quadratic Encoder for each Motor
The Quadratic Encoder needs to be the A/B type and be the same VCC as the Board.
If the Board counts backwards when the motor runs forward, the two quadratic input need to be swapped.
With an encoder attached to a motor, commands can be sent to set the motor to a specific position.
There are connections for a Station for each Motor
My previous version had the both motor encoder signals on the same port of the Microcontroller, this led to issues when positioning both motors at the same time. This version has the encoder signals for each motor on separate ports of the Microcontroller, this enables both motors to be positioned simultaneously.
A Station is a place for a switch to be fitted to a project, that when triggered, will set the position of the Motor to a known position.
There are two settings for a station depending on the direction of the Motor, some switches don't trigger at the same point when triggered form opposite directions.
Commands
The Motor Driver Board is controlled by commands on the I2C Bus.
The Board can be connected to any microcontroller that has I2C.
All commands start with any byte, this is because I have an ESP8266 and they haven't fixed the first data byte issue. When sending data via the I2C on the ESP8266 the first byte gets 0x80 added to it. So my driver ignores the first byte sent.
For simplicity I will use '#' as the first character of all commands sent to the Motor Driver.
The second byte is the Identifier that tells the driver the type of command. All commands are from the second byte onwards. I should say "char" as all commands are sent as ASCII characters.
Global Command 'M'
M1 = Motor A is the current motor that will be adjusted.
M2 = Motor B is the current motor that will be adjusted.
M3 = Motor A and B be adjusted.
A global command can be used on its own (preceded with '#') or at the end of other commands (preceded with a space)
'C' Commands (settings):
C1 = Sets the Current Position to 0 (zero). Just use C1.
C6 B<value> = Set: Has a Station Position. Boolean = 1 or 0 (true or false).
C7 P<value> = Set the Forward Station Position value. value = a 16 bit value, Sets the Station Position while moving Forward.
C8 P<value> = Set the Reverse Station Position value. value = a 16 bit value, Sets the Station Position while moving in Reverse.
C10 A<value> = Set I2C Address. value = 1 (0x00) to 127 (0x7F). This is to change the I2C Address of the device.
C13 B<value> = Set I2C Speed. Boolean; Is it 400k. value = 1 or 0 (true or false). 1 = 400000, 0 = 100000.
All setting are saved in non volatile memory.
No need to apply settings every time power it connected.
'S' Command (Speed):
S<Value> = Set the Speed 0 to 1000. This is a PWM value. So 500 would be 50% on 50% off square wave.
'F' Commands (Forward):
F0 = Stop. Can just use 'F' as the buffer will be full of zeros.
F1 = Forward at a current Speed.
F1 S<value> = Forward at a set Speed.
'R' Commands (Reverse):
R0 = Stop. Can just use 'R' as the buffer will be full of zeros.
R1 = Reverse at a current Speed.
R1 S<value> = Reverse at a set Speed.
'G' Commands (Go to):
G0 = Stop. Can just use 'G' as the buffer will be full of zeros.
G1 P<value> S<value> = Move to an absolute Position Forward (Positive) of zero at a Speed.
G2 P<value> S<value> = Move to an absolute Position Reverse (Negative) of zero at a Speed.
Settings that set a position are only valid with motors that have a Quadratic Encoder.
The 'G' code P<value> can be negative values. So why have G1 and G2?
To keep options open.
All positions are relative to a zero.
When writing your own code to control the Motors you may only have the option of Unsigned Integers.
You may want to only use Unsigned Integers to save memory.
A Typical 4 Motor setup
- One Microcontroller.
- Only I2C connection from your Microcontroller.
- Two Driver Boards.
- Four Motors With Quadratic Encoders.
- Each Motor has a Station to set the the zero position.
I have done an Instructable for Version 1 Tim's I2C Dual Motor Driver : 9 Steps - Instructables
- The only difference between version one and two is the Pin Configuration of the Microcontroller.
- Pin allocation has changed which requires a new PCB and Firmware.
- Programming the STM8S103F3 is the same, only use S19 files posted here.
This supersedes this Project. Tim's I2C Dual Motor Driver - Share Project - PCBWay
An example of how I use the board:
The video shows the reason for making version 2.
The new board now works as I expected, below is a video.
Tim's I2C Dual Motor Driver [Version 2]
*PCBWay community is a sharing platform. We are not responsible for any design issues and parameter issues (board thickness, surface finish, etc.) you choose.
- Comments(0)
- Likes(1)
- 池昊 PCBWAY品牌部 Oct 24,2024
- 0 USER VOTES
- YOUR VOTE 0.00 0.00
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
More by Tim Jackson
- Tim's I2C Dual Motor Driver [Version 2] This is Version 2 of my previous Tim's I2C Dual Motor Driver.This supersedes this Project. Tim's I2C...
- Tim's Mini Plotter 2 This is a PCBWay PCB Version of mini plotter I did quit a while ago, my original mini plotter I made...
- Tim's I2C Dual Motor Driver This board has been SupersededThe version 2 can be found here:Tim's I2C Dual Motor Driver [Version ...
- Tim's Pie Divider Tim's Pie DividerWhen that pie comes out of the oven and your tummy rumbles, who gets the largest pi...
- Tim's I2C Intelligent DC Motor Driver I am working on a project that needs about six Motors. There are many DC Motor Drivers available, Bu...
- Tim's PTC Hot Plate Controller [Fused version] This is a fused version of this: Tim's PTC Hot Plate ControllerInstructable at: Tim's Hot PlateFor c...
- Tim's PTC Hot Plate Controller This is a for a DIY Hot Plate, for soldering SMD to PCBs.The heater element that it controls are the...
- TIM-01 EYES This is a module to give my robot TIM-01 Eyes.With many projects controlled by an Arduino or similar...
- Tim's DC Motor Driver X6 Mk2 This board was designed to drive the motors controlling the arms on my robot TIM-01.I have a blog on...
-
-
-
-
-
-
3D printed Enclosure Backplate for Riden RD60xx power supplies
154 1 1 -
-